uniform vec2 chunk_pos;
uniform float global_illum;
uniform float wind;

smooth out vec3 normal;

void main(){
	vec4 pos = ge_VertexPosition;
	pos.x = mod(ge_VertexPosition, 100.0);
	pos.xy += chunk_pos;
	ge_Color = ge_VertexColor;
//	ge_TexCoord0 = ge_VertexTexcoord;

	normal = ge_MatrixNormal * normalize(ge_VertexNormal);

	float anim = wind * 2.0;
	int anim_mode = int(ge_TexCoord0.z / 10.0) % 10;
//	int n_anims = int(ge_TexCoord0.z / 100.0);
//	float tex_h = mod(ge_TexCoord0.z, 1.0);

	if(anim_mode == 1){
		anim = (anim + 0.5) / 1.5;
		vec2 anim_v = (vec2(cos(ge_Time + pos.x * 0.1), sin(ge_Time + pos.y * 0.1)) + 1.0) / 2.0;
		anim = anim * length(anim_v);

		vec3 p = vec3(sin(ge_Time * 0.1), cos(ge_Time * 0.1), 0.0);
		pos.x += 0.75 * anim * p.x;
		pos.y += 0.75 * anim * p.y;
	}else
	if(anim_mode == 2){
		vec2 anim_v = (vec2(cos(ge_Time + pos.x * 0.1), sin(ge_Time + pos.y * 0.1)) + 1.0) / 2.0;
		anim = anim * length(anim_v);

		vec3 p = vec3(sin(ge_Time * 0.1), cos(ge_Time * 0.1), 0.0);
		p.xy *= cos(pos.z * 20.0);
		pos.x += 0.4 * anim * p.x;
		pos.y += 0.4 * anim * p.y;
	}else
	if(anim_mode == 9){
		pos.z -= 0.25 * (1.0 + (wind + 1.0) * 0.5 * cos(ge_Time + pos.x * 0.5) * sin(ge_Time + pos.y * 0.5));
	}
/*
	if(n_anims > 1){
		ge_TexCoord0.y += tex_h * mod(floor(ge_Time * 20.0), float(n_anims));
	}
*/
	ge_Position = ge_MatrixProjection * ge_MatrixModelView * pos;
}
